<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%@ include file="Connections/conDB.jsp" %>
<% int validaSession = 4; %>
<%@ include file="Connections/session.jsp" %>


<%
String LoteId = request.getParameter("motLoteId");
String motLoteCod = request.getParameter("motLoteCod");
System.out.println("LoteID "+LoteId);
System.out.println("motLoteCod "+motLoteCod);

String rsId_lote = "";
String rsAnio = "";
String rsCodigo_baan = "";
String rsDescripcion = "";
String factura = "";

Driver DriverRs = (Driver)Class.forName(MM_conDB_DRIVER).newInstance();
Connection ConnRs = DriverManager.getConnection(MM_conDB_STRING,MM_conDB_USERNAME,MM_conDB_PASSWORD);
String query = "";
//out.print(query);
PreparedStatement StatementRs = null;
ResultSet Rsquery = null;

if (LoteId!=null && !LoteId.equals("")) {
	query = "SELECT id_lote, anio, codigo_baan, descripcion FROM lote WHERE id_lote = "+LoteId;
	StatementRs = ConnRs.prepareStatement(query);
	Rsquery = StatementRs.executeQuery();
	if (Rsquery.next()) {
		rsId_lote = Rsquery.getString("id_lote");
		rsAnio = Rsquery.getString("anio");
		rsCodigo_baan = Rsquery.getString("codigo_baan");
		rsDescripcion = (Rsquery.getString("descripcion")!=null)?Rsquery.getString("descripcion"):"&nbsp;";
	}
}

%>
<html>
<head>
<title>CIMA v2 - Motivo en contrato</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="miestilo.css" type="text/css">
<script>
var win1 = null;
var win2 = null;
//-------
function loteCat(){	
	win1 = window.open('lotes_catalogo.jsp?campo1=motLoteCod&campo2=motLoteId&campo3=motLoteIdDesc','LoteNum','top=350,left=400,width=340,height=270');
}	
//--------------
function winCatSilos(id_almacen,campo,tipo_grano,tipo_granoDesc,lote) {
	win2 = window.open('silos_catalogo.jsp?id_almacen='+id_almacen+'&campo='+campo+'&tipo_grano='+tipo_grano+'&tipo_granoDesc='+tipo_granoDesc+'&lote='+lote,'Silos_cat','top=210,left=250,width=320,height=265');
	//top=210,left=250,width=320,height=265
}
//--------
function enviaSubmit() {	
	document.form1.action="contratos_checa_motivo.jsp";   
	document.form1.submit();			
}
//-------

//-------
	function cierraVentanas(){
		obj1 = eval("win1");
		if (obj1 && !obj1.closed) {
			obj1.close();
		}			

		obj2 = eval("win2");
		if (obj2 && !obj2.closed) {
			obj2.close();
		}			

	}
//----------
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" background="images/fondo.jpg" onUnload="cierraVentanas()">
<br> <center> <form name="form1" method="post"> <table border="0" cellpadding="0" cellspacing="0" width="340"> 
<tr align="center"> <td class="titulos" colspan="3">'Motivo de Contrato'</td>
      </tr>
	
      <tr> 
        <td align="right" width="40%" class="etiqueta">&#149; Motivo/Lote</td>
        <td width="7">&nbsp;</td>
        <td> 
          <input type="text" name="motLoteCod" class="textfields" size="20" value="<%=rsCodigo_baan+"-"+rsAnio%>" onFocus="blur()" readonly>
          <input type="hidden" name="motLoteId" value="<%=rsId_lote%>">
          <input type="hidden" name="motLoteIdDesc">
          <a href="javascript:loteCat()"><img src="images/buscar.gif" width="15" height="15" class="cursor" border="0"></a></td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">A&ntilde;o</td>
        <td>&nbsp; </td>
        <td><%=rsAnio%></td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta"> C&oacute;digo Baan</td>
        <td>&nbsp; </td>
        <td><%=rsCodigo_baan%></td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Descripci&oacute;n</td>
        <td>&nbsp;</td>
        <td><%=rsDescripcion%></td>
      </tr>   	  
      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>
		</td>
      </tr>
      <tr align="right"> 
        <td colspan="3" class="nota">&#149; Datos Requetridos</td>
      </tr>
    </table>
<br>
  <table width="200" border="0" cellpadding="0" cellspacing="0">
    <tr> 
      <td align="center"> 
         <a href="javascript:enviaSubmit()"><img src="images/bAceptar.gif" width="79" height="18" border="0"></a>&nbsp;
		 <a href="javascript:window.close()"><img src="images/bCerrar.gif" width="82" height="18" border="0"></a>
      </tr>
</table>
</form>
</center>
</body>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
</html>
<%
if (Rsquery!=null) {
	Rsquery.close();	}
if (StatementRs!=null) {
	StatementRs.close();	}
ConnRs.close();
%>